<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script>
        /**
        function student (name){
            this.name = name;
        }
        //给student新增一个方法
        student.prototype.hello= function (){
            alert('Hello');
        };
            */
        //ES6之后,定义一个student的类
        class Student{
            constructor(name) {
                this.name = name;
            }
            hello(){
                alert('Hello!');
            }
        }
        var xiaoming = new Student('xiaoming');

        class XiaoStudent extends Student{
            constructor(name,grade) {
                super(name);
                this.grade = grade;
            }
            myGrade(){
                alert('我是一名小学生');
            }
        }
        var xiaohong = new XiaoStudent('xiaohong',1);//必须放在class XiaoStudent之后

    </script>
</head>
<body>

</body>
</html>